import 'reflect-metadata';
import MethodType from '../util/MethodUtil';

// type MyMethodDecoratorType = (
//   targetClassPrototype: any,
//   methodname: string,
//   dataprops: PropertyDescriptor
// ) => void;

function requestDecorator(methodType: MethodType) {
  return function (path: string) {
    return function (targetClassPrototype: any, methodname: string) {
      console.log('进入到方法装饰器', 'path:', path);

      // let TargetClass = targetClassPrototype.constructor;
      // let TargetClassObj = new TargetClass();
      Reflect.defineMetadata('path', path, targetClassPrototype, methodname);
      Reflect.defineMetadata(
        'methodType',
        methodType,
        targetClassPrototype,
        methodname
      );
    };
  };
}

export const get = requestDecorator('get');
export const post = requestDecorator('post');
